<template>
	<view class="bgbox">
		<view>
			<image src="../../static/image/bg.png" mode="" class="bgpic"></image>
		</view>

		<view class="editor">
			<view class="title">
				<view style="">标题:</view>
				<u--input placeholder="请输入内容" border="bottom" clearable v-model="title"
					:placeholderStyle="placeholderClass"></u--input>
			</view>
			 <view class="title" style="margin-top: 20rpx;"> 
			    <view style="width: 180rpx;">话题类型:</view> 
				<uni-data-select
				      v-model="value"
				      :localdata="range"
				    ></uni-data-select>
			  </view> 
			<markdown @input="huoqune2" />
		</view>
		<view class="btn" @click="publish">
			发布
		</view>
	</view>
</template>

<script>
	import {
		addoreditGushis,huati_list,
	} from "@/api/api.js"
	import markdown from '@/components/markdown.vue'
	export default {
		components: {
			markdown,
		},
		data() {
			return {
				// id: '',
				topics: [],
				title: '',
				content: '',
				huati_id: '1',
				placeholderClass: 'placeholderClass',
				show: false,
				value: 0,
				 /* range: [
				        { value: 1, text: "八字合婚" },
				        { value: 2, text: "十年运势" },
				        { value: 3, text: "前世今生" },
				], */
			}
		},
		methods: {
			huoqune2(val) {
				this.content = val
			},
  
            huatiList() {
				huati_list().then(res=>{
					this.topics = res.data.data.data;
					console.log(this.topics, "话题");
				})
            },
			publish() {

				if (!this.title) {
					return uni.$u.toast('标题不可为空')
				}
				if (!this.value) {
					return uni.$u.toast('话题类型不可为空')
				}
				if (!this.content) {
					return uni.$u.toast('内容不可为空')
				}
				addoreditGushis({
					// id: this.id,
					title: this.title,
					content: this.content,
					huati_id: this.value
				}).then(res => {
					uni.$u.toast(res.data.msg)
					setTimeout(() => {
						uni.navigateBack()
					}, 1000)
				})

			},
			
		},
		onLoad() {
			this.huatiList()
		},
		computed: {
		  range() {
		    return this.topics.map(topic => ({ value: topic.id, text: topic.title }));
		  },
		},

	}
</script>
<style lang="scss" scoped>
	.container {
		padding: 10px;
	}

	.title {
		display: flex;
		align-items: center;
		padding: 0 30rpx;
		font-size: 16px;
		// font-weight: 700;
	}

	button {
		margin-top: 10px;
	}

	.bgbox {
		position: relative
	}

	.bgpic {
		position: absolute;
		top: 0;
		left: 0;
		bottom: 0;
		right: 0;
		width: auto;
		height: auto;
		min-height: calc(100vh - 44px);
		z-index: 0;
	}

	.editor {
		position: relative;
		z-index: 997;
	}

	.btn {
		position: relative;
		z-index: 2001;
		margin: 0 auto;
		max-width: 600rpx;
		background-color: #275515;
		border-radius: 24px;
		margin-top: 36px;
		padding: 12rpx 110rpx;
		text-align: center;
		color: #fff;
	}

	::v-deep .toolbar {
		margin: 30rpx 15px;
		background-color: #fff;
		border: none;
		overflow: hidden;
	}

	::v-deep .editor-wrapper {
		margin: 0 15px;
		background: #fff;
		overflow: hidden;
		border-radius: 15px;
	}

	::v-deep .ql-container {
		box-sizing: border-box;
		padding: 12px 15px;
		width: 100%;
		min-height: 50vh;
		height: 100%;
		margin-top: 0;
		font-size: 16px;
		line-height: 1.5;
		border: none;
		border-radius: 6px;
	}

	.placeholderClass {
		color: #fff;
	}
	
	 ::v-deep .uni-select{
	        height: 60rpx;
			width: 500rpx;
	    }
</style>